MySqlSharp.Provider
Class MySqlConnection

Represents an open connection to a mySql database.

Constructor Summary
MySqlConnection()
         Initializes a new instance of the MySqlSharp.Provider.MySqlConnection class.
MySqlConnection(string connectionString)
         Initializes a new instance of the MySqlSharp.Provider.MySqlConnection class when given a string containing the connection string.

Property Summary
string ConnectionString
         Gets or sets the connection string used to open a connection with the mySql database.
int ConnectionTimeout
         Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.
string Database
         Gets the name of the current database or the database to be used once a connection is open.
string DataSource
         Gets the name the mySQL Server to which to connect.
string HostInfo
         Gets a string representing the server host name and the connection type.
int ProtocolVersion
         Gets an integer representing the protocol version used by current connection.
string ServerVersion
         Gets a string containing the version of the mySQL Server to which the client is connected.
System.Data.ConnectionState State
         Gets the current state of the connection.

Method Summary
System.Data.IDbTransaction BeginTransaction(System.Data.IsolationLevel iso)
         This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
System.Data.IDbTransaction BeginTransaction()
         This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
void ChangeDatabase(string database)
         Changes the current database for an open MySqlSharp.Provider.MySqlConnection.
void Close()
         Closes the connection to the database. This is the preferred method of closing any open connection.
System.Data.IDbCommand CreateCommand()
         This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
MySqlSharp.Provider.MySqlCommand CreateCommand()
         Creates and returns a MySqlSharp.Provider.MySqlCommand object associated with the MySqlSharp.Provider.MySqlConnection.
void Dispose()
         Releases the unmanaged resources used by the MySqlSharp.Provider.MySqlConnection.
void Open()
         Opens a database connection with the property settings specified by the MySqlSharp.Provider.MySqlConnection.ConnectionString. If no DataSource is specified, named pipes are used to connect to a local server.

Methods inherited from class System.Object
Equals, Finalize, GetHashCode, GetType, MemberwiseClone, ToString


Constructor Detail

MySqlConnection

public MySqlConnection()

Initializes a new instance of the MySqlSharp.Provider.MySqlConnection class.

When a new instance of MySqlSharp.Provider.MySqlConnection is created, the read/write properties are set to the following initial values. Properties - Initial value

  • MySqlSharp.Provider.MySqlConnection.ConnectionString - empty string ("")
  • MySqlSharp.Provider.MySqlConnection.ConnectionTimeout - 15
  • MySqlSharp.Provider.MySqlConnection.Database - empty string ("")
  • MySqlSharp.Provider.MySqlConnection.DataSource - empty string ("")
  • You can change the value for these properties only by using the ConnectionString property.


    MySqlConnection

    public MySqlConnection(string connectionString)

    Initializes a new instance of the MySqlSharp.Provider.MySqlConnection class when given a string containing the connection string.

    When a new instance of MySqlSharp.Provider.MySqlConnection is created, the read/write properties are set to the following initial values unless they are specifically set using their associated keywords in the MySqlSharp.Provider.MySqlConnection.ConnectionString property. Properties - Initial value

  • MySqlSharp.Provider.MySqlConnection.ConnectionString - connectionString
  • MySqlSharp.Provider.MySqlConnection.ConnectionTimeout - 15
  • MySqlSharp.Provider.MySqlConnection.Database - empty string ("")
  • MySqlSharp.Provider.MySqlConnection.DataSource - empty string ("")
  • You can change the value for these properties only by using the ConnectionString property.

    Parameters:
    connectionString - The connection parameters used to open the mySQL database
    Throws:
    System.ArgumentException - An invalid connection string argument has been supplied or a required connection string argument has not been supplied.
    Property Detail

    ConnectionString

    public string ConnectionString

    Gets or sets the connection string used to open a connection with the mySql database.

    Value:
    The connection string that includes the source database name, and other parameters needed to establish the initial connection. The default value is an empty string.
    Throws:
    System.ArgumentException - An invalid connection string argument has been supplied or a required connection string argument has not been supplied.

    ConnectionTimeout

    public int ConnectionTimeout

    Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.

    Value:
    The time (in seconds) to wait for a connection to open. The default value is 15 seconds.

    Database

    public string Database

    Gets the name of the current database or the database to be used once a connection is open.

    Value:
    The name of the current database or the name of the database to be used once a connection is open. The default value is an empty string.

    DataSource

    public string DataSource

    Gets the name the mySQL Server to which to connect.

    Value:
    The name the mySQL Server to which to connect. The default value is an empty string.

    HostInfo

    public string HostInfo

    Gets a string representing the server host name and the connection type.

    Value:
    The server hostname and the connection type.
    Throws:
    System.InvalidOperationException - The connection is closed.

    ProtocolVersion

    public int ProtocolVersion

    Gets an integer representing the protocol version used by current connection.

    Value:
    The protocol version.
    Throws:
    System.InvalidOperationException - The connection is closed.

    ServerVersion

    public string ServerVersion

    Gets a string containing the version of the mySQL Server to which the client is connected.

    Value:
    The version of the mySQL Server.
    Throws:
    System.InvalidOperationException - The connection is closed.

    State

    public System.Data.ConnectionState State

    Gets the current state of the connection.

    Value:
    A bitwise combination of the System.Data.ConnectionState values. The default is Closed.
    Method Detail

    BeginTransaction

    private System.Data.IDbTransaction BeginTransaction(System.Data.IsolationLevel iso)

    This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.


    BeginTransaction

    private System.Data.IDbTransaction BeginTransaction()

    This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.


    ChangeDatabase

    public void ChangeDatabase(string database)

    Changes the current database for an open MySqlSharp.Provider.MySqlConnection.

    Parameters:
    database - The name of the database to use in place of the current database.
    Throws:
    System.InvalidOperationException - The connection is not open.
    MySqlSharp.Provider.MySqlException - Cannot change databases.

    Close

    public void Close()

    Closes the connection to the database. This is the preferred method of closing any open connection.


    CreateCommand

    private System.Data.IDbCommand CreateCommand()

    This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.


    CreateCommand

    public MySqlSharp.Provider.MySqlCommand CreateCommand()

    Creates and returns a MySqlSharp.Provider.MySqlCommand object associated with the MySqlSharp.Provider.MySqlConnection.

    Returns:
    A MySqlSharp.Provider.MySqlCommand object.

    Dispose

    public void Dispose()

    Releases the unmanaged resources used by the MySqlSharp.Provider.MySqlConnection.


    Open

    public void Open()

    Opens a database connection with the property settings specified by the MySqlSharp.Provider.MySqlConnection.ConnectionString. If no DataSource is specified, named pipes are used to connect to a local server.

    If the SqlConnection goes out of scope, it is not closed. Therefore, you must explicitly close the connection by calling MySqlSharp.Provider.MySqlConnection.Close or MySqlSharp.Provider.MySqlConnection.Dispose.

    Throws:
    System.InvalidOperationException - Connection is already open.
    MySqlSharp.Provider.MySqlException - A connection-level error occurred while opening the connection.